/********************************************************/
/*	Copyright (C) 2016 Gong Li Bin		 	*/
/*	Project:	GlbRtbEng-1.0.0			*/
/*	Author:		gong_libin			*/
/*	Date:		2016_06_26			*/
/*	File:		GlbRtbDefs.h			*/
/********************************************************/

#ifndef	_GLBRTBDEFS_H
#define	_GLBRTBDEFS_H

#include <string>
#include <signal.h>

#include "GlbLog.h"
#include "GlbMap.h"
#include "GlbNet.h"
#include "GlbPro.h"
#include "GlbSet.h"
#include "GlbConf.h"
#include "GlbFile.h"
#include "GlbRwLock.h"

#include "GlbRtbAdvs.h"
#include "GlbRtbArea.h"

#define	GLB_RD_REQ			1	// request
#define	GLB_RD_RES			2	// response

#define	GLB_RD_TANX			11	// tanx

#define	GLB_RD_PBID			101	// bid
#define	GLB_RD_ADDR			102	// user ip
#define	GLB_RD_PPID			103	// pid
#define	GLB_RD_SIZE			104	// adv size
#define	GLB_RD_UAGT			105	// user agent
#define	GLB_RD_UURL			106	// user url
#define	GLB_RD_ADID			107	// advs id
#define	GLB_RD_MXCP			108	// max_cpm_price
#define	GLB_RD_SNPT			109	// html_snippet

#define	GLB_RD_FTTM			0x8000	// time
#define	GLB_RD_FTIP			0x4000	// area
#define	GLB_RD_FTUA			0x2000	// uagt
#define	GLB_RD_FTOS			0x1000	// os
#define	GLB_RD_FTMD			0x0800	// media
#define	GLB_RD_FTTY			0x0400	// type
#define	GLB_RD_FTAL			(GLB_RD_FTTM | GLB_RD_FTIP | /*GLB_RD_FTUA | GLB_RD_FTOS | GLB_RD_FTMD |*/ GLB_RD_FTTY)

#define	GLB_RD_PAIR			64	// kv pair
#define GLB_RD_ASET			100	// set total

typedef std::string GLBSTRING_C;

typedef GlbCls::CGlbMap<ULONG, USHORT, GlbCls::GLBMAPDIGIT_O> GLBRTBRESULT_C;
typedef GlbCls::CGlbMap<ULONG, USHORT, GlbCls::GLBMAPDIGIT_O>::GLB_ITE GLBRTBRESULT_IT;

typedef GlbCls::CGlbMap<GLBSTRING_C, GLBRAINFO_S**, GlbCls::GLBMAGLBTRING_O> GLBRTBINDEX_C;
typedef GlbCls::CGlbMap<GLBSTRING_C, GLBRAINFO_S**, GlbCls::GLBMAGLBTRING_O>::GLB_ITE GLBRTBINDEX_IT;

typedef struct tagGlbRtbReq
{
	char m_szBID[GLB_BYTE64];		// bid
	char m_szUIP[GLB_BYTE64];		// user ip
	char m_szAre[GLB_BYTE64];		// user area
	char m_szPID[GLB_BYTE64];		// pid
	char m_szSiz[GLB_BYTE64];		// size
	char m_szUag[GLB_KBYTES4];		// user agent
	char m_szUrl[GLB_KBYTES4];		// user url
}GLBRTBREQ_S;

typedef struct tagGlbRtbRes
{
	char m_szAID[GLB_BYTE64];		// aid
	char m_szBID[GLB_BYTE64];		// bid
	char m_szUIP[GLB_BYTE64];		// user ip
	char m_szPID[GLB_BYTE64];		// pid
	char m_szSiz[GLB_BYTE64];		// size
	char m_szMcp[GLB_BYTE64];		// max_cpm_price
	char m_szSnp[GLB_KBYTES4];		// html_snippet
}GLBRTBRES_S;

typedef struct tagGlbRtbConf
{
	char m_szDev[GLB_BYTE256];		// dev id
	char m_szSlp[GLB_BYTE256];		// sleep time
	char m_szReds[GLB_BYTE256];		// redis info
	char m_szRest[GLB_BYTE256];		// rest proto
	char m_szAdvs[GLB_BYTE256];		// GlbAdvs path
	char m_szArea[GLB_BYTE256];		// GlbArea path
	char m_szLogs[GLB_BYTE256];		// GlbLogs path
}GLBRTBCONF_S;

#endif /* _GLBRTBDEFS_H */
